package com.mxx.common.flow;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: mxx
 * @date: 2021/12/30
 * @time: 11:36
 * @Description: 描述信息
 */
public class Flows {

    private final List<Flow> flowList;

    private int index = 0;

    private String nameLine;

    public Flows(final List<Flow> flowList) {
        this.flowList = flowList;
        this.nameLine = flowList.stream().map(p -> p.flowName()).collect(Collectors.joining("->"));
    }

    public void remove(int index) {
        flowList.remove(index);
    }

    public void reset() {
        this.index = 0;
    }

    public int getIndex() {
        return index;
    }

    public boolean hasNext() {
        return flowList.size() > index;
    }


    public Flow next() {
        if (flowList.size() > index) {
            return flowList.get(index++);
        }
        return Flow.NIL_FLOW;
    }

    public Flow current() {
        return flowList.get(index);
    }

    public String getNameLine() {
        return nameLine;
    }
}
